import { Car } from '../car.entity'
import { ShopEmployee } from './shop-employee.entity'
import { JoinTable, Entity, OneToMany, ManyToMany, PrimaryGeneratedColumn } from 'typeorm'
import { ManyToOne } from 'typeorm'
import { Shop } from './shop.entity'
// 工单
@Entity()
export class ShopWork {
  @PrimaryGeneratedColumn()
  id: number

  /**
   * 汽车
   * 一个汽车有多个工单，一个工单有一个汽车
   */
  @ManyToOne(type => Car, car => car.works, { cascade: true })
  @JoinTable()
  car: Car

  // 店铺
  @ManyToOne(type => Shop, shop => shop.works, { cascade: true })
  @JoinTable()
  shop: Shop

  /**
   * 施工者
   * 一个工单有多个施工者，一个施工者有多个工单
   */
  @ManyToMany(type => ShopEmployee, employee => employee.works, { cascade: true })
  employees: ShopEmployee[]
}
